const state = {
  isCollapse: JSON.parse(sessionStorage.getItem("isCollapse")) || false, //也可以改用localStorage ，不过需要手动清除缓存
};

const getters = {
  //类似于computed
  count: (state) => state.count + 10,
};

const mutations = {
  SET_COLLAPSE(state) {
    state.isCollapse = !state.isCollapse;

    sessionStorage.setItem("isCollapse", JSON.stringify(state.isCollapse)); //还可以用cookie_JS
  },
  SET_COUNT(state, value) {
    // state代表仓库，value是传进来的值, 外面通过  this.$state.commit('方法名',传入的值) 来调用
    state.count = value;
    console.log(state.count);
  },
};

const actions = {
  login(context, requestData) {
    return new Promise((resolve, reject) => {
      //接口
      Login(requestData)
        .then((res) => {
          resolve(res);
        })
        .catch((err) => {
          reject(err);
        });
    });
  },
};


export default {
  namespaced:true,
  state,
  getters,
  mutations,
  actions
}
